package com.kalvin.kvf.common.utils;

public class CamelToUnderscoreConverter {

    //驼峰转下划线  keywordName  转   keyword_name
    public static String camelToUnderscoreConverter(String str) {
        StringBuilder output = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            // 如果当前字符为大写字母，则在其前面添加下划线，并将其转换为小写字母
            if (Character.isUpperCase(c)) {
                output.append("_");
                output.append(Character.toLowerCase(c));
            } else {
                output.append(c);
            }
        }
        String result = output.toString();
       return result;
    }



}